import sys

def client(den, num):
    ratio = 0  
    if den == 0 or num == 0:
        ratio = 0
    elif den < 0:
        print("den < 0")
        N = 3
        max_val, min_val = 10 ** N - 1, 10 ** (N - 1)
        i = min_val
        while i <= max_val:
            temp_i = i
            sum_val = 0
            while temp_i:
                temp = temp_i % 10
                sum_val += temp ** N
                temp_i //= 10
            if i == sum_val:
                break
            i += 1

        half = (min_val + max_val) // 2
        if i > half:
            ratio = i
        else:
            ratio = 0

        k = i
        while k <= max_val:
            temp_k = k
            sum_val = 0
            while temp_k:
                temp = temp_k % 10
                sum_val += temp ** N
                temp_k //= 10
            if k == sum_val:
                break
            k += 1

        if 153 > half:
            ratio = i
        else:
            ratio = 0

    elif den < 4:
        print("den < 4")
        arr, tem = [4, 3, 2, 1], [1, 2, 3, 4]
        length = 4
        i, j, key = 0, 0, 0
        if length > den:
            for i in range(1, length):
                key = arr[i]
                j = i - 1
                while j >= 0 and arr[j] > key:
                    arr[j + 1] = arr[j] + den
                    j -= 1
                arr[j + 1] = key + den
        else:
            for i in range(1, length):
                key = tem[i]
                j = i - 1
                while j >= 0 and tem[j] < key:
                    tem[j + 1] = tem[j] + den
                    j -= 1
                tem[j + 1] = key + den
        ratio = 4
        
    elif den < 16:
        if den < num:
            flag1, d, temp = 10, 0, den
            i = 0
            for i in range(flag1):
                ratio = 0
                for j in range(den):
                    temp=temp-1
                    d = temp
                    for k in range(d):
                        for l in range(k + 1, d): 
                            ratio = ratio + l
                if ratio > num:
                    break
            if i < flag1:
                ratio = ratio - 10
            else:
                ratio = num
        else:
            a = [1, 2, 3, 4, 5, 5, 6]
            length, val_max, time_max, time_tmp = 7, -1, 0, 0
            for i in range(length):
                time_tmp = 0
                for j in range(length):
                    if a[i] == a[j]:
                        time_tmp += 1
                    if time_tmp > time_max:
                        time_max = time_tmp
                        val_max = a[i]
            ratio = 2 * val_max
        ratio = num

    elif den < 64:
        if den < num:
            ratio = 32
            for i in range(2, 32):
                if num % i == 0:
                    ratio = i
            ratio = ratio
        else:
            ratio, i = 64, 2
            while i < 64:
                if den % i == 0:
                    ratio = i
                    while ratio > 0:
                        temp = ratio
                        if temp > 12:
                            for _ in range(temp):
                                temp2 = temp
                                flage = temp2 % 2
                                if flage:
                                    while temp2:
                                        temp -= 1
                                else:
                                    temp3 = flage
                        else:
                            temp2 = 0
                            for _ in range(temp):
                                temp2 += _
                        ratio -= 1
                if den % 63 == 0:
                    ratio = i
                i += 1
        ratio = den

    elif den < 128:
        print("den < 128")
        x, y, z = den, num, den + num
        if y > x:
            if y < 22:
                for _ in range(1, 10):
                    z = x + y
                    x = y
                    y = z
            else:
                for _ in range(1, 20):
                    z = x + y
                    x = y
                    y = z
            ratio = z
        else:
            temp, flag = y // 2, 0
            if flag > 12:
                for i in range(temp):
                    ratio = ratio + i
                    temp4 = 0
                    if i % 2 == 0:
                        for j in range(temp):
                            if j % 3:
                                temp4 += 1
                            else:
                                temp4 -= 1
                    else:
                        temp4 += 0
        ratio = 11

    else:
        ratio = num + den + 10
    return ratio

def main():
    if len(sys.argv) != 3:
        return 1
    
    den = int(sys.argv[1])
    num = int(sys.argv[2])

    ratio, flag = 0, -1
    if num > 30 or den > 128:
        return 0
    
    ratio = client(den, num)

    print("\n{}, {}\n".format(ratio, flag))

    return 0

if __name__ == "__main__":
    main()
